Propagate exceptions to tests thread and rename port configs
Implement non blocking write
Small refactor for log method
Shutdown cleanly. Deregister listeners and close sockets.