Wrote functions and according tests.