preservationmeter: Refactor and testing

* Refactored lots of code on API
* Added a test

Signed-off-by: Joao Goncalves <jsvgoncalves@gmail.com>