Possible solution to error found by junit test