fix race condition in tests, make test helpers compile for tests only
fix race condition in listener.go