Added handshake tests, fixed encoding issues.