WIP tests and refactor doc generator