Adding logging. Further developed func. test.