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.