Working version of refactored code

Includes one very simple unit test of very limited scope