Configuration, refactor, and tests

/cc @nbryan

Just for review.