Code clean-up and reformat
Further add() tests added. Errors found.