beautify and add tests