move isRaw to util
improve factory
add test