Opensource fixes

Adding test cases to increase coverage with minor refactoring in core classes