Configuration simplification and tests

I've tried to remove some duplication and add some tests for the configuration class.