[doc] map and flatmap examples
refactor defer tests