Add a wrong branch test for the api and clean up some of the api code

Small test fixes
Add the auth middleware to the deploy api