Add serialization tests to selftest.