Backport the following two commits:
```
commit a6a3e58c483700bd5f2bc7d117a621e0c4af60e3
Author: John Newbery <john@johnnewbery.com>
Date: Fri Feb 17 14:22:56 2017 -0500
Various review markups for rpc-tests.py improvements
commit 3de3ccdfaaa5edcf4e0924860d960e7e0db5a9b9
Author: John Newbery <john@johnnewbery.com>
Date: Mon Feb 6 09:07:14 2017 -0500
Refactor rpc-tests.py
- add main()
- remove global variables
```