Ruby 1.8.7-compat way to undef test classes

add cleanup after each definition
Merge pull request #2890 from rolandwalker/portable_class_undefine

Ruby 1.8.7-compat way to undef test classes