Added (nearly) full test coverage