Extract dependency loading and add unit tests for it

Re-written dependency loader. Known issue is that a dependency loop with
softDepends will not load the hard depending plugin.