Write some functional handler tests

Also found / fixes a few issues thanks to this!