Add failing test for saving kernel history on Python 2
Fix ``%history -f foo`` in kernel.

Closes gh-4582
Merge pull request #4713 from takluyver/kernel-history-py2

Fix saving kernel history in Python 2