Extracted doctests into a test module

Extracted the doctests out of grid.py into a test_grid.py module in
tests/

Added a few more tests to increase coverage.