added jsdocs, commenting and a few new tests