Fixed some issues:
* `registerDefs` needs to have the required object otherwise it's hard
  to get the correct path for the `require`
* Wrapped certain functions in types.js to bind the `types` variable
* Used the instance of `types` instead of the prototype for adding functions/vars
* Added a better error message to `Def.field` if the object is finalized
* Added a simple test