Factored out the next and prev operations, and boundary tests, into their own m-files.  Added unit tests and they pass.  Presently working on triangle optimization but it's not done yet.