Partial refactoring + testing documentation