unit-tests: Add cleanup test cases for different thread exit situations