Add tests and refactor repeitions module.