added test suite and did some polishing