Added test cases and enhancements. Not completely functionaly yet.