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
`isMacGUI` instead? Or is this general purpose due to the `force_gui` option?