Move workspace setup to functions.sh

And add a test script that exercises the logic of the git repo
checkout functions.  Current test errors are annotated and commented
out.

Change-Id: I2e04787999a64cd8aaa238ce0374898032a9d8bd