Improve code for ClusteredQueryTest