test for queries over relations + queries bug fix