Fix for issue #5.

Fix + test. @yawn pls review and improve ;).