Refactor sign-in and decouple tests