Replace assertEquals with assertEquals for Py3.
Work around IPython bug.

Use `execute` instead of `with view.sync_imports`.
Whitespace tweak.
Get `range` from `six` for Py3 compatibility.
Handle different repr of `None` under Py3.