core: refactor check for valid pid

move into header and remove redundant condition
core: add doxygen header for kernel_types
core/msg: add DEVELHELP checks for valid pid