Rework library loading to provide better error reporting
Add a test for the new library load error reporting