Rework test_main to use FakePopen.

FakePopen will make the migration to check_call easier, and narrowly
replaces the engire rather than replacing the subprocess entry point.

Change-Id: Ic868ce4cdbef79f256ef01a9a030767522b855a3
Switch to StringStream.

In Python 3 stdout is a text stream not a byte stream, so we should be
prepared for that.

Change-Id: I4bc1151e491226f24591e9b3436db8d5d37fca65