Testing dyn loading

This adds testing capability for testing dynamic loading. It also makes dynamically loading modules exception safe(r) by moving exception throwing operations out of constructors and destructors.