Added internal tests.
Mistakenly removed writeIORef while refactored.