Adding unit test + fix