tls/tests: fix a race condition