Fixed some out-of-date test cases, and fixed some minor bugs in Query condition