junit tests added, small changes in code