Fix issue with offset.
Improve unittests.