Fixes to SSLSocket, ready for testing