Remove possible infinite loop from test_scan.
Cursor of 0 should also be treated as None.
Add comments to test_scan explaining the magic 20 loops.
Merge branch 'feature/issue-816-fix-test-scan' into develop