Bug fixes
Initial tests for new API