Fix deltafun cumsum

This is a fix for #1289. Appropriate tests have also been added.