Reimplemented flatmap and implemented the flatMap test