Raise TypeError only if it is segment type that has problems

It raised TypeError also when module did not have required function