flake8

- remove unused imports
- improve code example block so it is compilable
- reorder code in threadedhttp to avoid triggering a flake8 error

Change-Id: I352c5f32528f91b9a1ec4df1c929f32a3c621f30
Merge "flake8"