JSDoc and test breaking refactoring
Improve test covering and bug fix