LRSIX-4205 - updated scripts with functions and status codes, and pre-checking for branch existence