made sure initial array elements are preserved

Code comment from @megawac made me realise that if initial arrays
contained array elements, those were flattened which is not what we
want. This commit fixes that (and adds tests).