Add unit test and correct offset calculation.