Added main guard
Unit tests.
Cleaning up code.'