RF: refactor npdot segfault tests

Refactor tests to use loop parameters.

Some PEP8 and whitespace cleanup, add comments.
Merge pull request #2 from matthew-brett/for-sturla-2

RF: refactor npdot segfault tests