Upmerge and add test

Hi, would you consider merging this in?
* Upmerge to master
* Adds test