SPARK-2269 Refactor mesos scheduler resourceOffers and add unit test

Can you add a comment on why this is needed?