Improved error handling in flatMap and filter.
Added tests for promise