Code cleanup

Cleaner code and better messages in the upload application.
Add tests

Added tests for verifying that the actual measurements uploaded are
correct.