Bug fixes and completing test coverage