Improve robustness of some test utilities