Moved all test cases into separate function. This could be merged with the actual tests.