Optional callback on client.connect

Improved API doc
Code styling: jshint'ed
Common config and local config for unit tests
Overridable default consistency
Upstream merge