Test and fix bugs in auth