Added specs for primality function and factored for some ioc