Modified extend to treat plain javascript objects as namespaces when used as options for import/constructor or the content of a register call.

Added more tests and created test hooks for private functions.

Added JS doc comments.