Refactoring configuration handling.
Adding a few basic tests.