HtmlUnit does not behave properly (like the browsers) when working with <script> elements.
We found the problems when working with Richfaces ModalPanel and were able to track it down a bit further.
Here are the problems we found:
1. The main problem: when moving a script element to another parent, the source is executed twice for IE in HtmlUnit. In our case two instances of ModalPanel where created what lead to some trouble.
I think the cause is a fix introduced for issue 993940. Now (for IE) script.text and body.appendChild both (re)execute the source but in real IE only script.text (re)executes it.
2. When replacing the source of a script element from within the same script element, this should lead to an execution of the new source in the IE. The FF does not execute it (this works fine in the current implementation).
3. When replacing the source of a script element from within another script element, this should lead to an execution of the new source in both IE and FF. Currently this does not work in either browser.
4. The methods appendChild and insertBefore do not work in real IE but do work in IE in HtmlUnit. The first IE supporting these methods is IE9.
See attached a patch file adding some tests to HTMLScriptElementTest. I have checked the expectations for IE6, IE8 and FF13 (I know, it's to up-to-date, sorry...). Not all tests are failing currently but perhaps you can use them for regression tests.