Adds index tests and fixes .csi swappage bug

This adds some tests for the indexing code, and fixes a bug where loffset was not swapped correctly in .csi files when writing on big-endian platforms.