[BUGFIX] Avoid race condition in tests

Resolves: #58717
Releases: 6.2

Change-Id: I592445971e464abeb0e85ceddd6d470703df74d8
Reviewed-on: https://review.typo3.org/30021
Reviewed-by: Nico de Haen
Tested-by: Nico de Haen