Implemenation & tests for authentication workflow