Thanks for the instructions to reproduce the issue, it helped to identify the problem and fix it. Select required some function to be executed in order to initialize some of its internal buffers and it didn't happen when executing kemi scripts. I pushed fixes to master branch, I am going to backport to stable branches these days.
If you want to test with master branch right now, let me know the results in your side.