Added test case to test Stage. multiple bugfixes.