Moved tests to just semaphore, and fixed thread joining