Modify test to avoid random failures