Refactor spec authentication into factory