Add unit test mode to build-local.sh.
Only compile unit tests when not cross-compiling, slightly better 'detection' of compiling for openwrt.
Fix several compilation warnings.