Refactor master module into class, start writing tests.