Add code for cancelling a test; finalize API