Fix #1024
Unit test