add ticket encoding and appropriate tests