Added flatMap and quick tests