Fix compatibility with 1.8.7

The behavior of `Module#const_defined?` is different in the 1.8.7 and 1.9.x.