When reasonably possible, the program should only crash in debug mode. Adds a couple of extra unit tests to prevent regressions and adds docs. Fixes <https://github.com/koreader/koreader/issues/5356>.