Added standard context validity check, another check for a replace function and corrected a return statement to fit our standard code style. Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com> Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>