memory test and fixed middleware bug