adding test coverage and fixing bugs revealed by said test coverage