query_tests: make more robust