CTest: fix regressions introduced by the ctest-fix-run-serial topic

The first regression resulted in endless looping due to unrun test
dependencies. The second regression prioritized all tests with dependencies
in serial test runs.
Merge topic 'fix-ctest-regressions' into next

dfdf3b0 CTest: fix regressions introduced by the ctest-fix-run-serial topic