Adding test case, and fixing pass by reference bug to pass the test