WIP refactor tests working, index almost there