Fix various issues:

- Use DI for creation to allow user-configuration of backends
- Correct some method signatures
- Fix bootstrapping issues with cookie key configuration
- Fix issues with database being operated on when not ready (such as when using testsession)
- Fix issue with cookie expiry of 0 being misinterpreted
Using config like this seems very slow compared to just overwriting canWrite in a subclass when you want it to not call !headers_sent()