Revert "bug in query" -- unit tests got broken

This reverts commit 7e0d95f0765041e3ea1094b9c14c5e813e9a363a.