Test for query using criteria