implement method passing in constructor and add tests