Deletion function and tests