added working tests, fixed code so it works with targetContext