Move storing password/username after checking password

The cookie encryption is quite expensive, so let's move it after we
check password validity.

Signed-off-by: Michal Čihař <michal@cihar.com>
Adjust testcase to new split methods

Signed-off-by: Michal Čihař <michal@cihar.com>
Define missing variable

Signed-off-by: Michal Čihař <michal@cihar.com>
Always restore mocked instance after test

Signed-off-by: Michal Čihař <michal@cihar.com>
Add missing call to test

Signed-off-by: Michal Čihař <michal@cihar.com>
Fix variable name

Signed-off-by: Michal Čihař <michal@cihar.com>
Merge branch 'master' into multiquery