varying/test+bug: add first tests for flatMap, fix related bugs.