Primary problem is in your script "testDollar$Test". This is not correct script, because groovy try to find variable "Test".
Good question is why was this script successfuly saved, if every saved attribut should be validate. The reason is simple, this script is valid (for example this is unvalid script "testDollar$"), but cannot be evalued (because variable "Test" missing).
So your exception is not throwing during validation of the script, but during evaluation of that script (because I try to save historic value if the attribute was changed).
My advice is: Do not save incorrect scripts :-). If you have some automatically utility for create this attributes (may be some WF), you have to fix it, because generating incorrect scripts.
I want to prevent this situation for next time. So I modified saving of the attribute and script is validate and executed now too. For next time will be not possible to create attribute with incorrect groovy script.
I modified save method for situation when the attribute (script) is already broken. In this case need to obtain old value (for save historic value). If script exception will be throw in this situation I only catch the exception and historic value will be not saved.
Commit: https://github.com/bcvsolutions/CzechIdMng/commit/454933a3d9a728f5f65354d984812ee2f8978ac8