exit code should be between 0-255 and fix tail check and add error details into result