SPARK-2269 Refactor mesos scheduler resourceOffers and add unit test

This is difficult to read. Style should be:
```
scheduler.resourceOffers(...)
  .filter(...)
  .foreach { offer =>
    offer.foreach { taskDesk =>
      val slaveId = taskDesc.executorId
      ...
    }
  }
```