Refactoring of handshake.

* Removed function handshake and make userAuth more generic.
* Use request.message() during handshake.
* Removed and added some TODOs.