cleaned up and added some tests for cfg