Renamed multithreaded related functions, added simple unit tests and fix bugs caught by said tests :)