add generalized lucas theorem method and tests