NPM Usage Patch

Changes included allow for this to be used as a library. In the future you might want to look at separating the lib code from a test application that consumes it. Awesome stuff though; definitely publish this to npm.