Introduced error handling and made test passing.
Permissions test
make unittests executes all unit tests.