Tests, fixes and cleaning