Added thread locks and cleaned up some test cases