add more tests
moduled the code
added test case