Refactor plugin

* Use better and more consitent variable names
* Extract local functions to simplify logic
* Make non-public functions local
* Add rake task for running tests
This is required for `vspec`. There's a comment online 93. I originally had this config wrapped in a comment `begin/end` block. Would that have been clearer?