Improve tests and fix get_django_preferred_languages