refactor query test