Fix #326 + unit test