The method parseVariable from org.compiere.util.Env class will parse some text using the provided PO class. When the variable is not present in the PO, you can use the parameter keepUnparseable to determine if the variable will be deleted from the text or if it will remain there.
This is working when the PO class is provided, but when the PO class is null the variable is ripped off the text regardless the parameter keepUnparseable.
Here is a simple test you can run in Tools > Script:
Attached you can find the fix