Fix TCP tests and bugs

Use RWMutex again for restarting, wrap check in a method.

Remove listeners on close. Fixes reusing listeners in tests.

Create global listener if not created in NetManager()