Added unit test for array append and fixed code.