[1.7.x] Fixed #23039: Don't try to serialize unmanaged models in tests