Exec command exit code and logging improvement

as discussed in #343 #277