Add memory usage tests

Port memory usage tests from Kefir. Adds also diamond shaped stream and
combineTemplate test cases form PerformanceTest.