Added SQL function for deleting/updating segments, tests also updated to reflect new additions