refactored test and modifyed calculation method to input method