Fix and cleanup tests