MULE-6926: flaky test. Partially cherry-picked from commit 2788183ef5539ec1033586e2f1b1ece38eb77fbb.