Fix for Bug 18558

These commits add a new failing test case to demonstrate the serialization bug and the code that eliminates it.