improved/refactored Linux/Mac code to run tests in their own threads