Pass argv to main

This will make it easier to do high-level testing because we'll be able
to call main from tests and pass it arguments

Change-Id: I2bac44a746cd61fda963df622b0a775bf4bf31c2
Modularize to enable easier testing

Change-Id: I85c5d95658c0be57c4ce87fac53556475ae53207