refactor that implementing append using foldLeft
add a failture test for flat