Fixes race condition in test. Closes #9389. Upstream-commit: 19844140d338bae8cc56ab0f3318a613859581ea Component: engine