Better array casting and test evaluation (fixes #2)