Make morsel_to_cookie more pythonic

Fix a pep8 error. Prior to fixing this, I implemented some tests to cover the code I was fixing.

Fixes #1771