Exit with non 0 code when an error happens

and output the error
Add comments to functionnal test