Minor api updates

New test cases

Internal refactorings