Tests and fixes for Issue #2

Hi!
I'm pushing tests and fixes for Issue #2 in this pull request, so please accept.