Fixed tests and bug for Ruby 1.8