Bug 51158: clear out Memory-based part before writing to it, except for PictureData items, which keep the original image data in the Part-object directly. Add reproducer-unit tests and enhance some related unit tests