Fixed a potential concurrency bug
Fixed a compile error in unit test