Correct failure when psutil is not installed.

Reformatting.
Merge pull request #9335 from cachedout/ps-unit-tests

Correct failure when psutil is not installed. Also some minor reformatting.