Fix branch_exists function to actually work

Change-Id: Ib574547b1366408064f7f224af3a3944d37af82a