First batch of unit tests.

All parts of system module now have unit tests.