RF: refactor npdot segfault tests

Refactor tests to use loop parameters.

Some PEP8 and whitespace cleanup, add comments.