Make (de)serialization for arrays error-safe

Amend tests