Refactor certificate generation class