fix add and delete if there were an error and better tests and docstrings