This borrows heavily from the inttest for gpb, many thanks to Luis Rascão for providing a most useful example.