Modified delete() function and updated tests