Fixes partiality of marshall/unmarshall.

These functions were throwing errors rather than returning a failure.
Initial work on tests.