Fix bugs, write Readme, add tests