Fix timeout processing, add tests and docs