Add some unit tests of the unflatten function