refactored flatmap tests