Test connect race with dispatch group and atomic flag

Here's another take on testing the `-connect` race in #856. I think it's good, but if someone catches a problem with it, I won't be surprised.