moved some queries in various tests to the right place
removed some redundant queries in various tests