handle flags more consistently
add error formatting to tests
add comments