better tests for python API, raise 500 on invalid expression