fixed bugs in query system
basic tests for query system