mm: pte: Fix memory leak, add test and fix bugs

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>