refactor functions

- move set up of core singletons to bootstrapper
- create overloads for dependencies on singletons (will help later for
unit tests)
- group some common functions together (e.g., CryptoFunctions)
fix signature bug

In the last commit, I accidentally swapped the order of the signature
and the encrypted value in the auth cookie. I also made the
encrypt-and-sign function a bit more tolerant.