Move unittest-specific code into unittest block.

To avoid causing conflicts in user code.