Refactor tests

Test are refactored to separate functionality and to enable reuse in users of the provider.
I tried. Moving this requires a large change to the `django-oauth2-provider`. I started it but could not finish it in time.