Testing and fixing stage sorting