#16 Add test and fix wrong index offset.