Module generators are using standard *_add_instance() methods which helps with testing, it also updates grades and calendar events if used.