Test cases
And making the code work. More verbose than I would like, but working