Fix #1045 and #1146

https://github.com/Azure/azure-sdk-for-node/issues/1146
https://github.com/Azure/azure-sdk-for-node/issues/1045