Add quality tests and fix