refactoring the changed code line number judgement part

refactoring the part which judge the changed line num of code. so it would return the accurate line number but not with unchanged context. And add the test cases for this refactoring. thank you.