Converted to be a node module, and added some tests for the
maths (currently failing).