Pass in sys as an argument to main

This allows the substitution of mock argv, stdout and stdin.
Add a full system test

This brings libproton to 100% coverage.