start to modularize the lib for browser and node use
also retrofittng tests (yeah i know i'm lame)