added flatMap
map test adjustment
code cleanup