Fixed ThreadPool and added some test cases.