organized index.js, wrote some additional tests.