Fixed some formatting and got rid of a helper function in `socks.py`.
Fixed control-flow logic starting from `SOCKSProxy._handleHandshake()`
by adding error guards and additional logging information to the
relevant handler methods. Also moved some logic into
`_handleBadRequest()`, where it belonged.