added tests, fixed bugs, added mergerules jsdoc