added sample_period parameter and generalized test code for get/set test to simplify it