Added a multithreaded test. Cleaning up code