Improve test coverage and eliminate some issues