Fixing threading issue in unit test.