Added some additional authentication code and testing.