Fix and clean up main tests
Add proper exit codes

Closes #28