Makes code more suitable for unit testing.
Implements unit tests.