Adding unit test.
Better exception handling to deal with handshake algorithm support per Ivan Ristic's comment.