Refactor and add tests for plugins.py

Improvement to the tests currently being run on ``plugins.py``

related #644 
I'm not sure. Maybe @mtomwing has a better opinion?