Two test cases fail, because name.trim() and contents.trim() will throw NPEs when respectively name and contents are null.

Maybe it is a better idea to do the precondition validation as preconditions on all methods, instead of afterwards in a validate() invariant :-)