Bug fix

Hi Ken, I found two little bugs in the code which lead to failed authentication and false failed authorization. I corrected them in this pull request. Please take a review.

-T