factor out expect and consume into wrapper class