Added error event, isConnected(), callback for disconnect(), and relevant tests.