The test-query fails executing when you expand a parameter as a tablename.
This is logic you *CAN* use so it should be able to work in test.
It works fine when using it runtime
@tablename = "FooBarEntity" wiuth expand-inline to true
SELECT atn.Id, atn.Name
FROM {@tablename}