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