fixed issue #48, use proper exit code on error
add exit code tests
Merge pull request #54 from gabrielf/master

fixed issue #48, use proper exit code on error