Added unittest for #issue2618 and missing return statement

Fixed #2618 (wrong issue number on commit message :))