made changes as per comments on PR, added extra unit tests