Added unittest for #issue2816 and missing return statement