Custom exception instead error logging, updated tests, tiny refactoring