--- a/test/tc_parser.rb
+++ b/test/tc_parser.rb
@@ -302,7 +302,12 @@ class TestParser < Test::Unit::TestCase
     assert_nil(error.str2)
     assert_nil(error.str3)
     assert_equal(0, error.int1)
-    assert_equal(20, error.int2)
+    # Versions of libxml2 before 2.9.2 calculated wrong error columns.
+    if Gem::Version.new(XML::LIBXML_VERSION) < Gem::Version.new('2.9.2')
+      assert_equal(20, error.int2)
+    else
+      assert_equal(34, error.int2)
+    end
     assert_nil(error.node)
   end
 
--- a/test/tc_html_parser_context.rb
+++ b/test/tc_html_parser_context.rb
@@ -6,19 +6,22 @@ require 'test/unit'
 
 class TestHtmlParserContext < Test::Unit::TestCase
   def test_default_options
+    XML.default_keep_blanks = true
     context = XML::HTMLParser::Context.new
     assert_equal(0, context.options)
   end
 
   def test_no_options
+    XML.default_keep_blanks = true
     context = XML::HTMLParser::Context.new
     context.options = 0
     assert_equal(0, context.options)
   end
 
   def test_options
+    XML.default_keep_blanks = true
     context = XML::HTMLParser::Context.new
     context.options = XML::HTMLParser::Options::NOERROR
     assert_equal(XML::HTMLParser::Options::NOERROR, context.options)
   end
-end
\ No newline at end of file
+end
