Fix RModel IO, fix unittests