Copied serialization tests from paymentlib.