Refactor and add tests for plugins.py

Improvement to the tests currently being run on ``plugins.py``

related #644 
This code was originally added as part of commit 3027cc1f