add test for returning Error from f in flatMap