Fix logging
Add test