removed repetitions in convert() code
check that type-validation works