Added more code contracts to Grave and refactored unit tests.