Xsdir tests

Half closes #328. I wrote tests for the existing functionality as is (except two spots which were broken). I think a good case could be made for some API changes, but I figured I would write tests first.