Authentication improvements

Add login and change password endpoints.

Also simplifies error handling and makes speed_test.py more deterministic.