cleaned up some code with loading configs.
added some tests.