Fix test by using sleep instead of db check