Test coverage and bug fixes