1. Some error handling on the sockets
2. Some fixes on the unittests