Refactor demo to use raise_for_certificate