added tests and fixed the top 3 algorithm