Better error handling
Minor
Avoid failing test due to race condition