Add unit tests, clarify a few things