add self type assertions in class and module methods
move the common case up