Refactoring /random-prime web and API