Added delete_safe logic and tests