Authorization complete
Cleans up authorization + adds some tests