There's an issue with the undo handling. The AddUndo(UNDOTYPE_NEW) needs to be called after the insertion of the object. Here the docs (see the Note: "In case of creation... after insertion..."). Also AddUndo(UNDOTYPE_CHANGE), while it needs to be called before the actual change, it may only be called on entities which are part of the document.
Think about it. The undo functions are functions of BaseDocument. The undo system wants to keep track of changes inside a document.
For a change (matrix, parameter change,...) of an entity (entity, because it's the same for objects, tags, materials...), which is already part of the document, you call AddUndo() before the change, because C4D needs to back up the state before the change (simplified, it will copy the entity's BaseContainer onto the undo stack).
For a new entity, though, it will need to keep some reference to the new entity, in order to be able to remove it on undo (simplified, internally it will store a BaseLink (sorry, link to C++ docs, BaseLink class does exist only in C++) to the new entity on the undo stack). This can only work´reliably, if the entity is already part of the document, as BaseLinks are always evaluated in a document context, so AddUndo() has to be called after the insertion.
You may be of the opinion, I'm nit picking, because you script seems to be working. Yet, I'm not. Wrong usage of the Undo functions can severely damage C4D stability.
For your script the steps are:
1) Create Null
2) Insert Null
3) AddUndo(NEW, Null)
4) Actually no AddUndo(CHANGE, Null) needed at all, as you just modify a freshly inserted object. Where would be the point in backing up it's initial state in the same undo step as its creation? If the user presses undo, the object will be removed, there's no use of C4D restoring the initial state prior to removal...
Cheers