Let's begin with the code listing:
Code listing
Now, the problem. As you can see, I have a class (MyEntity) that allows me to partially copy entity parameters (entity_transfer = deepcopy(entity) seems to break the game, sadly). All fields are copied according to their keys, except health. When I try to copy (and use it in math lib) entity.health - it returns nil value. Even when I explicitly set entity_transfer.health = entity.health it still is a nil value. Only thing that comes to mind is that entity stops being entity with health right before it is mined. Do you people have anything to say about this? Maybe (and I really hope so) I'm just not very smart and I'm missing something. I really don't want to write another event handler, just to copy entity.health...I'm using Factorio 0.14.8, no other mods except mine, WIN 7.
EDIT: All's well now, big thanks to aubergine18