[MNG-3494] Fixed a bug I introduced with the last commit. All ITs run now, and I've improved the unit test to make sure that bug doesn't reappear.