Refactoring, beginning to mockout tests for the plugin