testcases pass. Some digi specific stuff to remove to make it pull requestable