Fix regex to avoid warning with Ruby 1.8.7
Add unit test for #177, #228