Fix a bug with not releasing the lock in testsuite