Add test and fix #1108

Sorry if this took me time.