Added unit testing

Part of the main file now includes some unit tests that can be switched
on or off.