functionality for authorization + refactored tests