Fix MiddleWare registration and execution.

This patch will bomb the tests!!! 
Mostly because I don't really get the unit tests. I will need some help with them.

* Only SecurityMiddleware was registered. All others failed silently because they were just added to an array that wasn't used.
* Execute tests in the same order they were registered. The AppFramework **app** runs `afterException` in reverse order as how the middleware was registered. That meant that a controller method which should **not** run was executed **before** SecurityMiddleware kicked in!
* Removed unused counter in MiddlewareDispatcher.
* White-space fixes.

@DeepDiver1975 @Raydiation @karlitschek