Fixes for issues 136 and 177

During the integration of ADAL into our project I had to do these two bug fixes to get things to work.