tests: Make some tests more robust.