Fixes some bugs found with unit tests
Makes it work without a document
Adds a unit test runner with nodejs