Add test for flatten
Related to #4