Bug fixing: error array growing in each function call, doc typos and test fix