Added check for undefined values
Added tests for last added functions