SPARK-2269 Refactor mesos scheduler resourceOffers and add unit test

Style should be
```
mesosTasks.foreach { case (slaveId, tasks) =>
  d.launchTasks(...)
}
```