More Tests added and code cleanup