tests: fixed test cases that could fail due to random timing error.