Moved the new credentials provider loading code into a static method for testing.
Added tests for the credentials provider loading code.