add more tests and javadoc for queries