Add spec for marshalling, closes #793