Some polishing and added tests