Refactoring of MetricClient ; add initial tests