Addressed pull request issues with tests and error checking