Added comment doc
Completed tests in JS and created function for the special case to simplify objects with arrays.