Amazing, I corrected as you mentionned and I have pushed the new version on github. We might need to work on the speed and complexity of the implementation since this is very slow compared to the C++ implementation.
Thank you for your help, if you have any inputs to make it faster, let me know.