Unit tests pass now (bugfixes in C distance function)