[proivder_resolution] Fix provider resolution code and add tests.

Summary:
Provider resolution logic was broken, fix it, add tests, fix providers.py which had some errors in it (found in testing). Yay testing.
Fixes T297

Test Plan: Run unit tests that now test provider resolution.

Reviewers: emfree

Reviewed By: emfree

Maniphest Tasks: T297

Differential Revision: https://review.inboxapp.com/D331