Refactor code in preparation for pre-rolled metrics support
Unit tests changes
Integration tests changes