Fixed locking issue in tests

Change-Id: I3706cfa46f82615b8cc677bcaaa207d5ab05bf40