A few minor fixes which are missed from the previous push. An additional test is added.