Fixed unexpected behaviour
Added graph unit tests