Port tests from d7 and fix up failures'

I prefer using entity manager directly as opposed to calling procedural functions. My personal preference, you can ignore if you prefer this approach.