Fixed error handling when https-request fails early.
resolved some jslint warnings