Add executable example

This moves logic out of main, and provides a smoke test for the actual
logic in main.
Remove redundant example code