Split helper and repeat search.
Merge pull request #3160 from ximenesuk/fix-search-tests

Try search repeatedly until success