Some cleaning up and test added