Added tests for flatten function