Extract promise util functions
Improve map and tap
Clean up flatMap a bit.  Flip internal when() function arg order to be in curry-friendly order