tests on function added + basic refactoring in tests