Fix tests to work automatically

Also simplify local table name generation