add test for flatten func