fixed coverity CID 1013823, added unit tests
Merge pull request #62 from lesserwhirls/coverity

fixed coverity CID 1013823, added unit tests