Add helpers: repeat, define/invoke. Code cleanup. Tests for new helpers