Significant rewrite to make testing and configuration simpler.

Dependencies mostly now injected.
Default factory to get similar to old behaviour.
Also moved to using the PSR3 logger interface.

This is a significant, api breaking, change.