Improve stability of tests