Port tests from d7 and fix up failures'