Add initial tests
Rename FlatMap to Map
Add test for invalid inputs, and refactor