Refactor

Refactored the component to use a notion of providers, which are iterated through. More reusable and extendable.

Also made more testable through more unit tests. Full pass on the tests, and covers everything except cookie setting.