textlib_tests.py: restore value before self.assert

If assert statement raises an error, the correct value is not resored.
Move restoring of value before self.assert statement.

Change-Id: Iffea89f8910bd05001e2b1480ce89b491276a632