Unserialization fixes, validation and tests