fix len(query) usage in tests