write unit test for thread