Adding a function test and fixing a bug where error would not be propagated