Merged the changes from pull request 31 into master and added a test case