refactor config to be testable and add tests