fixed minor issues in queries and tests