Fixes exception when log is empty

This fixes an exception I would receive if there was no log yet, which usually happens if the project is not built yet.

Also added a test.