new query clause and fixed tests