Refactor and add more tests
add config tests