A two-stage rank test using density estimation