Refinements to common code and Login test