unit tests and code for cancellation manager