Import original test shell from AppEngine.

* Tweak output for regularity.
* Fix i/j mixup in single test mode.
geom/layout: Import the layout library from AppEngine.