fixed data race caused by test and addressed PR comments