Add deserialize method and tests for it