MODE-2054 Verified that the new query engine in 4.0 correctly handles the reported problem

Added a new test case that verifies the query engine behaves correctly in 4.0.
Merge pull request #1222 from rhauch/mode-2054

MODE-2054 Verified that the new query engine in 4.0 correctly handles the reported problem