Add more test cases and fix another query parsing bug