Fix for issues #3 and #4 with regression test for #3
Merge pull request #5 from domurtag/master

Fixes for #3 and #4 (locale dependence and thread-safety issues). Many thanks to @domurtag / @kaufda.