Added more tests for conditional queries (JAVA-358)