fixed some legacy compatibility bugs.

now correctly finds package.json, resolves native modules and fallsback
to using legacy package structure.  also refactored tests and code.