Added tests for add() and fixed #770