A minor refactor in wsgi.py

A minor refactor to move the code up in the file as suggested by termie
and henry regarding the review comments in
https://review.openstack.org/#/c/26487/

Fix bug 1166697

Change-Id: I890415c755dd383749f2d4382f53d0b3a6badc6c
Merge "A minor refactor in wsgi.py"