Remove some duplicate code from req_delete.c and req_deletearray.c and write unit tests for it. Also write some additional unit tests for req_delete.c.