Refactoring. Move is_prime method to global scope and add spec.