Fix flaky test by adding a delay