Added additional validation on a query. Added unit tests to verify this validation.