Failing the test after 10 iterations without a loading error is problematic because it may take 11 iterations to get a loading error.
Fix that by running until a loading error occurs, which should happen in almost all runs within the first 10 iterations.
This is a backport of [[https://github.com/bitcoin/bitcoin/pull/20569 | core#20569]]
Note: I added a timeout condition to the "infinite" loop, in case the race only happens in two of the 3 threads (the third one could then load/unload the wallet forever without interference) or in case the race is accidentaly fixed in the c++ code.