Change invalidtarget function and finally have some unit tests in our code