Disconnect fails if called after createConnection and before 'connect' event handler

also added a test for it