Fixed crash at end of masterlist update.

Was due to trying to get the repo path from a closed repo handle.
Added test for loot_sort_plugins.