Add some specs and start to refactor authentication