cmake: fix tests

Code to add tests got messed up in successive iterations to fix Cmake
code. This ensures that tests are now executing as expected.
21 jobs for !5179 with 20929-file-chooser-improvements
latest merge request