(test) Refactor logic for checking email