fix issue with Else and slightly refactor login

@jburel: this should fix the error you see with running the Insight UI tests