Fix the #48 and clean up the code

Just as the discussion, clean up the code in cortex_m.py and also checked other target's inheritance function, no same issue discovered.
@tkuyucu, may be you can help to test this patch on nrf target?