Use Tornado 3.x in tests.
Refactored tornado test cases.

Use an explicit IOLoop instance so it should be more clear what's going
on internally.