Merge to master and Test for [FIXED JENKINS-15806]

I merged the code from pull request #31 and the master, as well as added a test as requested in the comments of the original pull request.