improved px to ems function - now accepts context