Fixed error throwing in non-flash targets + new unit test