Add wait and retries in a test for background event sync