Test coverage improvements and minor fixes