fixes #7

How about this? I added a couple of tests too.