Rewrite query tests

:information_source:  This is a maintenance PullRequest<sup>1</sup>

**The following actions may be done:**
* [ ] find the branch maintainer (or someone who cares enough)
* [ ] find/create a work package on openproject.org for this PR
* [ ] decide if the commits in this branch are still meant to be integrated
* [ ] delete the branch if the proposed change shall not be integrated
* [ ] rebase the branch on a current `dev`; test it

<sup>1</sup>: This PR was created to reduce the huge number of stale branches (branches which are older than 6 month and don't have a pull request). The goal is to give those branches a platform for review and discussion and -- on the long term -- either integrate or delete them.