More logical indexing fixes, and add a few more tests