[#1349] Fix plugin loading code in some tests

This fixes a problem that extra_public_paths were not working in the
tests.

load_plugin() and unload_plugin() should probably become shared test
helper functions.