Backport PR #4121: move test_kernel from IPython.zmq to IPython.kernel

I don't know how it managed to get left behind.

Should be backported to 1.1
Backport PR #4132: Fixed name error bug in function safe_unicode in module py3compat.
Backport PR #4088: Fix coalescestreams line with incorrect nesting causing strange behavior
Backport PR #4120: support `input` in Python 2 kernels

input is just `eval(raw_input(…))`

closes #3990