NullPointer bug fix

There was a bug on cache_control line 35 - a typo of the nil check.
Have added some generator tests to test the entire middleware which
would have caught this error.