Streamlines code per reviewer's suggestions.
Adds tests for logical operator validation.