remove races by adding syncs

Adding those `syncs` remove some races in the tests for me. `TestMultipleAttachRestart` passes and it was failling for 2 weeks now.