LUN-718: changed the way plugins in PLUGIN_TEMPLATE_REFERENCES
should behave. Raise errors when settings are not configred correctly.
LUN-718: Added tests for form validation on plugins templates.
+ Some code refactoring.