I cannot see a Joseph Stewart/Stuart in the 1841 census in Midlothian area that could fit but there is this entry in 1841 which may well be Joseph due to the Goodwin name:
James Goodwin 30, Gin & Beer Brewer b. Scotland
Eliza Goodwin 25 b. Scotland
Joseph Goodwin 10
James Goodwin 7
Eliza Alexander 8
Address: Shakespeare Square 7, Edinburgh
The use of two surnames in Joseph's trial paeprs may simply mean that his mother remarried and Joseph was known under two surnames perhaps.
Monica