Fix encoding/decoding of timestamps

Fixes absolute validity fields.
Test coverage increased; many bugfixes
Increase test coverage
Cleanup