GDA-5584 (fix test by protecting against NPE)

also remove duplicated code for unlimited dimensions