Improve autoscroll, and add tests.