correcting a race condition in test code detected by race detector.
fixed race conditions detected by go test -race
fixed race condition detected by go test -race