SPARK-2269 Refactor mesos scheduler resourceOffers and add unit test

This is actually just a refactor of what's already in the backend, I don't actualy know why we need to set and restore class loaders