refactoring to accept threads and added two thread to test