Add tests

Timedelta encoding is causing a segfault. Apparently when encoding
a negative value right after a positive value, the SIGSEGV is
received.