Refactor steps to individual methods.

There's several different parts to this piece of software, so it would
be nice to be able to make sure the different parts are working
correctly. What I've done in this commit, is move the steps out into
their own methods. This will allow them to be ran against a hash of test
cases to see if they're working as intended. I've gone ahead and added
the testing code as well.