Use method_defined? to make tests work with ruby 1.9