Factor out the key loading logic to make it easier to have other key loading schemes
Merge pull request #1249 from alex/factor-key-loading

Factor out the key loading logic to make it easier to have other key loading schemes