refactored, using executorservice instead of thread.sleep, added test