refactored the cancellation code

Got rid of some copy loops. Hopefully a bit more readable as
well.
adds and clarifies some frontend tests