test coverage pass:
refactor and cleanup to improve coverage for corner cases