Fix TCP tests and reorder unregister connection