adding tests, cleaning up index.js and adding docs