Add tests + improve serialization of arrays