Fix leak
Add unit test
Merge pull request #1 from creack/bug/creack/fix-mem-leak

Bug/creack/fix mem leak