Fixed bug with resaving sdata. Added new test for this case.