Refactored metric_handler

Split out into simpler classes.
Add tests
Merge pull request #8 from malcyL/refactorings-squashed

Added tests and made various refactorings