Fixed crashes.

Changed SelfTester to work on non-Windows platforms.
Fixed 2 crashes with villager inventory.