Fix randomly failing tests