fix offset error. full test demo added