Adding constructor and instance tests, small modifications on middleware api