Fixed issues on racing condition on tests.