test refactoring
added sleep for race conditions