Some refactoring to make c# more integratable
Test case is now broken, but not for long