added function to check the input, some changes to ease unit testing, bug fix.
added function to check the input, some changes to ease unit testing, bug fix.

thehyve/naa-SmartR,agapow/smartr,thehyve/heim-SmartR,agapow/smartr,thehyve/heim-SmartR,thehyve/naa-SmartR,thehyve/heim-SmartR,agapow/smartr,thehyve/naa-SmartR,agapow/smartr,thehyve/heim-SmartR