Test full flow

Adds test cases to verify the full functionality of the web service and contains several bug fixes in relation to the Middleware