Added options parameter to createConnection to support secure connections.
DRY'd up some of the logic shared with createClient.
Updated unit test