Improved test coverage and reworked authorisation endpoint