Python 2.6 compatibility

Signed-off-by: Michal Čihař <michal@cihar.com>
Test for relogin

Signed-off-by: Michal Čihař <michal@cihar.com>
Better error message

Signed-off-by: Michal Čihař <michal@cihar.com>
Test automatic relogin on HTTP 502

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