Improve code for posting measurements. Refactor tests.