added initial code from toSchema and basic tests