name functions more consistently
enhance test to cover more code branches