Alikins/certlib refactor

Yeah, this guy again.

Ignoring the commit history, do these changes look useful?

They try to make the *libs and certmgr more logical, and inject more things
(all uses of identity, facts, etc), and updates a lot of the tests to use the
injected versions instead of mocking.