Some minor code simplify and extra test