Fixes to make tests more resilient